import com.wh.proxy.UserService;
import com.wh.proxy.UserServiceImpl;
import com.wh.proxy2.ProxyInvocationHandler;
import org.junit.Test;

public class MyTest2 {

    @Test
    public void test(){

        //真实角色
        UserServiceImpl userService=new UserServiceImpl();
        //代理角色
        ProxyInvocationHandler pih=new ProxyInvocationHandler();
        //设置代理的对象
        pih.setObject(userService);
        //动态生成代理类
        UserService proxy = (UserService) pih.getProxy();
        proxy.query();
    }
}
